package com.um.jdy.app.base.manager;

import cn.hutool.core.bean.BeanUtil;
import com.um.jdy.common.base.enums.YesOrNo;
import com.um.jdy.common.shop.entity.po.Keyword;
import com.um.jdy.common.shop.entity.vo.KeywordVO;
import com.um.jdy.common.shop.service.KeywordService;
import com.um.springboot.starter.orm.manager.BaseManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * 管理类：搜索热门关键词
 */
@Component
public class KeywordManager {

    @Autowired
    KeywordService keywordService;

    public List<KeywordVO> getHotKeyword() {
        List<Keyword> list = keywordService.getList(new String[]{"type", "in_search_input"},
                new String[]{"Shop", YesOrNo.No.name()});
        return BeanUtil.copyToList(list, KeywordVO.class);
    }

    public KeywordVO getSearchKeyword(){
        Keyword entity = keywordService.getEntity(new String[]{"type", "in_search_input"},
                new String[]{"Shop", YesOrNo.Yes.name()});
        return BeanUtil.toBean(entity, KeywordVO.class);
    }

}
